package demo1.Assignment3;

import java.util.Map;

public class FacultyMemberAdapter {
    public FacultyMember adapter(UserInfo userInfo) {
        FacultyMember fm = new FacultyMember();
        fm.setName(userInfo.getName());
        fm.setContactTelephone(getTel(userInfo));
        fm.setIdentification(getIf(userInfo));
        return fm;
    }

    private String getTel(UserInfo userInfo) {
        String res = "";
        for (Map.Entry<String, String> entry : userInfo.getUserTeles().entrySet()) {
            res = entry.getValue();
            break;
        }
        return res;
    }

    private String getIf(UserInfo userInfo) {
        return userInfo.getNumber() + String.format("%04d", Integer.parseInt(userInfo.getId()));
    }
}
